#ifndef __RISCV_IT_H__
#define __RISCV_IT_H__

#include "main.h"

extern volatile int8_t byte_read;

#define MTVEC_MODE_CLINT_DIRECT           (0U)
#define MTVEC_MODE_CLINT_VECTORED         (1U)
#define MTVEC_MODE_CLIC_DIRECT            (2U)
#define MTVEC_MODE_CLIC_VECTORED          (3U)

#define WDT_INTERRUPT_SRC                           (0U)
#define GP_TIMER_INTERRUPT_SRC                      (1U)
#define BOOT_SSI_INTERRUPT_SRC                      (2U)
#define GP_SSI_INTERRUPT_SRC                        (3U)
#define MAILBOX_INTERRUPT_SRC                       (4U)
#define UART_INTERRUPT_SRC                          (5U)
#define I2C_INTERRUPT_SRC                           (6U)
#define GBE0_INTERRUPT_SRC                          (7U)
#define GBE1_INTERRUPT_SRC                          (8U)
#define USB0_INTERRUPT_SRC                          (9U)
#define USB1_INTERRUPT_SRC                          (10U)

#define MCPU_DEST                         (0U)
#define ACPU_DEST                         (1U)

void set_interrupt_mode(uint8_t mode);
void enable_interrupt(uint8_t interrupt_src, uint8_t interrupt_dest);
void disable_interrupt(uint8_t interrupt_src, uint8_t interrupt_dest);

/* Globals week interrupt handler function */

void __attribute__((weak, interrupt ("machine"))) __mtvec_clint_vector_table(void);
void __attribute__((weak, interrupt ("machine"))) software_handler (void);
void __attribute__((weak, interrupt ("machine"))) timer_handler (void);
void __attribute__((weak, interrupt ("machine"))) external_handler (void);
void __attribute__((weak, interrupt ("machine"))) default_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) wdt_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) gp_timer_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) boot_spi_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) gp_spi_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) mailbox_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) uart_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) i2c_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) gbe0_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) gbe1_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) usb0_vector_handler (void);
void __attribute__((weak, interrupt ("machine"))) usb1_vector_handler (void);
void __attribute__((weak)) default_exception_handler(void);

#endif //__RISCV_IT_H__